package com.df.springmvc.system.manage.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.df.springmvc.common.bean.MsgBean;
import com.df.springmvc.common.util.WebUtil;
import com.df.springmvc.system.manage.services.LogoutServices;


@Controller
@RequestMapping("/system/manage/Logout")
/**
 * 本类仅做一些简单数据处理如:
 *格式验证
 *数据封装
 * @author David
 *
 */
public class LogoutController{
	String page_model="system/manage/" + this.getClass().getSimpleName().replace("Controller","") + "_";
	@Autowired
	LogoutServices loginServices;
	@Autowired
	MessageSource messageSource;
	
	public LogoutController(){
		// TODO Auto-generated constructor stub
		
	}
	@RequestMapping(value={"/"},method=RequestMethod.GET)
	public String login(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		return page_model;
	}
	@RequestMapping(value={"/doLogout"})
	public void doLogout(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		try{
			request.getSession().invalidate();
			WebUtil.json(response,new MsgBean("用户成功注销!",true));
		}catch(Exception e){
			// TODO: handle exception
			WebUtil.json(response,new MsgBean(e.getMessage(),false));
		}finally{
		}
	}
}
